package cqrtplm.controller;

import com.hustcad.plm.pdm.enumeration.service.TyplmEnumerationService;
import com.ty.basic.constant.ApiPathConstant;
import com.ty.basic.response.ResponseResult;
import cqrtplm.service.FromDataService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping(ApiPathConstant.PRODUCT_VERSION_ONE_PATH + "fromData")
public class FromDataController {

    @Resource
    private TyplmEnumerationService typlmEnumerationService;

    @Resource
    private FromDataService fromDataService;

    /**
     * 查询成本中心枚举
     * @return
     */
    @GetMapping("/getSporadicProcurementCostCenterEnum")
    public ResponseResult getSporadicProcurementCostCenterEnum() {
        return ResponseResult.success(
                typlmEnumerationService.getEnabledItemListByEnumDefKey("SporadicProcurementCostCenter"));
    }

    /**
     * 根据物料编码查询 关联的图纸   描述文档和CAD
     * @param partNumber
     * @return
     */
    @GetMapping("/getCADByPartNumber")
    public ResponseResult getCADByPartNumber(@RequestParam String partNumber) {
        return ResponseResult.success(fromDataService.getCADByPartNumber(partNumber));
    }



}
